
package fhedu;

import javax.microedition.lcdui.Graphics;
import javax.microedition.lcdui.Image;
import javax.microedition.lcdui.game.GameCanvas;

public class frmXemLichHoc extends GameCanvas {
    
        Image lichhoc=Image.createImage(400, 320);
        Image chitietlh=Image.createImage(400,140);       
        CellPH thu[]=new CellPH[7]; 
        Graphics g=getGraphics();
        Graphics glichhoc=lichhoc.getGraphics();
        Graphics gchitiet=chitietlh.getGraphics();
        Cell cell;
        int focus=0, xchitiet=0;
        
        
    frmXemLichHoc(){
        super(false);
        VeLichHoc();
        Refresh();
    }
    void Refresh()
    {
        g.drawImage(lichhoc, 0, 0, Graphics.TOP|Graphics.LEFT);
        flushGraphics();
    }
    void VeLichHoc()
    {
       glichhoc.setFont(MyFont.fontnhodam);
       gchitiet.setFont(MyFont.fontnhodam);
       try {
       Image bg=Image.createImage("Image/bgmenu.png");
       glichhoc.drawImage(bg, 0, 0, Graphics.TOP|Graphics.LEFT);
       }catch(Exception e){}; 
       String ten="Bùi Thanh Minh";
       glichhoc.drawString("Lịch học của: "+ten, 5, 50, Graphics.TOP|Graphics.LEFT);
               
       
       String[] tenthu={"Thứ hai", "Thứ ba", "Thứ tư", "Thứ năm", "Thứ sáu", "Thứ bảy", "Chủ nhật"};
      
       for(int i=0;i<7;i++)
       {
           thu[i]=new CellPH(tenthu[i], 60, 20, Mau.mauden, 0x808080, 0xF7F6E6) ;
           thu[i].canle=0;
           thu[i].VeCell(glichhoc, 0, 80+i*20 );
           thu[i].x=0;
           thu[i].y=80+i*20;
           
       }
       
       thu[0].Focus(glichhoc);
       String[] tieude = {"Thời gian","Phòng", "Môn học", "Giảng viên", "Trạng thái"};
       glichhoc.setColor(0x808080);
       glichhoc.fillRect(60, 80, 5, 140);
       for(int i=0;i<5;i++)
       {
       cell=new Cell(tieude[i], 80, 20, Mau.mauden, 0x606080, 0x808080);
       cell.canle=0;
       cell.VeCell(gchitiet, 0+i*80, 0);
       }
      cell=new Cell("", 400, 20, Mau.mauden, 0x606080, 0x808080);
    //  cell.canle=0;
      cell.VeCell(gchitiet, 0, 70);   
       
    // for(int i=0;i<5;i++)
    // {
    //   cell=new Cell(tieude[i], 80, 20, Mau.mauden, 0x606080, Mau.mautrang);
    //   cell.canle=0;
    //   cell.VeCell(gchitiet, 0+i*80, 70);    
    //   }        
       
       String[] cai1sang={"6h45->9h25", "P51", "ASP.NET", "Lê Hữu Dũng", "Học"};       
       for(int i=0;i<5;i++)
       {
       cell=new Cell(cai1sang[i], 80, 25, Mau.mauden, 0x606080, Mau.mautrang);
       cell.canle=0;
       cell.VeCell(gchitiet, 0+i*80, 20);    
       }
    
       String[] cai2sang={"9h45->11h25", "P51", "ASP.NET", "Lê Hữu Dũng", "Học"};
        for(int i=0;i<5;i++)
       {
       cell=new Cell(cai2sang[i], 80, 25, Mau.mauden, 0x606080, Mau.mautrang);
       cell.canle=0;
       cell.VeCell(gchitiet, 0+i*80, 45);    
       }
        
        //////////////////////////////////////
       String[] cai1chieu={"12h45->3h25", "P51", "ASP.NET", "Lê Hữu Dũng", "Học"};       
       for(int i=0;i<5;i++)
       {
       cell=new Cell(cai1chieu[i], 80, 25, Mau.mauden, 0x606080, Mau.mautrang);
       cell.canle=0;
       cell.VeCell(gchitiet, 0+i*80, 90);    
       }
    
       String[] cai2chieu={"3h45->5h25", "P51", "ASP.NET", "Lê Hữu Dũng", "Học"};
        for(int i=0;i<5;i++)
       {
       cell=new Cell(cai2chieu[i], 80, 25, Mau.mauden, 0x606080, Mau.mautrang);
       cell.canle=0;
       cell.VeCell(gchitiet, 0+i*80, 115);    
       }
       // g.drawRegion(lichhoc, xchitiet, 0, getWidth()-65, 140, 0, 65, 80 , Graphics.TOP|Graphics.LEFT);
        glichhoc.drawImage(chitietlh, 65, 80, Graphics.TOP|Graphics.LEFT);
    }
    public void keyPressed(int k)
    {
        switch(getGameAction(k))
        {
            case UP:
                thu[focus].UnFocus(glichhoc);
                thu[focus-1].Focus(glichhoc);
                focus--;
                Refresh() ;             
                break;
            case DOWN:
                thu[focus].UnFocus(glichhoc);
                thu[focus+1].Focus(glichhoc);
                focus++;
                Refresh();
                break;
            case LEFT:
                xchitiet=xchitiet+10;
                glichhoc.drawRegion(chitietlh, xchitiet, 0, getWidth()-65, 140, 0, 65, 80 , Graphics.TOP|Graphics.LEFT);
                Refresh();
                break;
            case RIGHT:
                xchitiet=xchitiet-10;
                glichhoc.drawRegion(chitietlh, xchitiet, 0, getWidth()-65, 140, 0, 65, 80 , Graphics.TOP|Graphics.LEFT);
                Refresh();
                break;                
        }
    }
}
